#!/bin/sh
#
# /etc/rc.d/wpa_supplicant: start/stop wireless interface
#

. /etc/conf.d/wpa_supplicant
. /etc/rc.subr

NAME=wpa_supplicant
PROG=/sbin/wpa_supplicant
PIDFILE_WPA=/var/run/$NAME.pid

PROG_DHCP=/sbin/dhcpcd
PIDFILE__DHCP=/var/run/$NAME.pid

OPTS="-B -P $PIDFILE_WPA -D nl80211,wext -c /etc/wpa_supplicant.conf -i $DEV"
OPTS_DHCP="--waitip -h $(/bin/hostname) -z $DEV"

case $1 in
	start)
		msg "Starting $NAME..."
		start_daemon $PROG $OPTS
		
		msg "Start dhcpcd..."
		start_daemon $PROG_DHCP $OPTS_DHCP
		;;
	stop)
		msg "Stopping $NAME..."
		stop_daemon $PROG
		
		msg "Stopping dhcpcd..."
		stop_daemon $PROG_DHCP
		;;
	restart)
		$0 stop
		sleep 1
		$0 start
		;;
	status)
		status_daemon $PROG
		status_daemon $PROG_DHCP
		;;
	*)
		echo "Usage: $0 [start|stop|restart|status]"
		;;
esac

# End of file
